package poly2;

class termNode implements Comparable {
	private int exp;
	private double coeff;
	private termNode next;

	public termNode(double coefficient, int exponent) {
		coeff = coefficient;
		exp = exponent;
		next = null;
	}

	public termNode(termNode inTermNode) {
		coeff = inTermNode.coeff;
		exp = inTermNode.exp;
	}

	public void setData(double coefficient, int exponent) {
		coefficient = coeff;
		exponent = exp;
	}

	public double getCoeff() {
		return coeff;
	}

	public int getExp() {
		return exp;
	}

	public void setNext(termNode link) {
		next = link;
	}

	public termNode getNext() {
		return next;
	}

	public String toString() {
		if (exp == 0) {
			return (coeff + " ");
		} else if (exp == 1) {
			return (coeff + "x");
		} else {
			return (coeff + "x^" + exp);
		}
	}

	public int compareTo(Object other) {
		if (exp == ((termNode) other).exp)
			return 0;
		else if (exp < ((termNode) other).exp)
			return -1;
		else
			return 1;
	}

}